home *** CD-ROM | disk | FTP | other *** search
/ Vypalování CD / Vypalovani-CD-cd1.bin / Backup-Burner Add-On SDK 5.0 / ExampleSource / Delphi / Unit1.pas < prev   
Pascal/Delphi Source File  |  2002-03-23  |  6KB  |  170 lines

  1. // ----------------------------------------------------------------------------
  2. //
  3. //  Project:
  4. //  Example of using Delphi with Backup-Burner Add-on SDK
  5. //  February, 2002
  6. //  ⌐Desernet Broadband Media, Inc.
  7. //  Produced by: D. Clark
  8. //
  9. //  Compiles in Delphi 5 without hints, warnings, or errors.
  10. //
  11. // ----------------------------------------------------------------------------
  12.  
  13. unit Unit1;
  14.  
  15. interface
  16.  
  17. uses
  18.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  FileCtrl,
  19.   Registry, StdCtrls, Menus, Buttons;
  20.  
  21. type
  22.   TForm1 = class(TForm)
  23.     Label1: TLabel;
  24.     Label3: TLabel;
  25.     Label4: TLabel;
  26.     ResultsLabel: TLabel;
  27.     Memo1: TMemo;
  28.     Button2: TButton;
  29.     Button3: TButton;
  30.     MainMenu1: TMainMenu;
  31.     File1: TMenuItem;
  32.     Exit1: TMenuItem;
  33.     N1: TMenuItem;
  34.     BackuptoCD1: TMenuItem;
  35.     Label5: TLabel;
  36.     OpenDialog1: TOpenDialog;
  37.     procedure TwoButtonClick(Sender: TObject);
  38.     procedure ThreeButtonClick(Sender: TObject);
  39.     procedure ExitClick(Sender: TObject);
  40.  
  41.   private
  42.     { Private declarations }
  43.   public
  44.     { Public declarations }
  45.   end;
  46.  
  47. var
  48.   Form1: TForm1;
  49.   ResultCode: Integer;
  50.     BBRegName,
  51.     BBRegCode,
  52.     BBVolume,
  53.     BBTitle,
  54.     BBColorForm,
  55.     BBColorText,
  56.     BBFolderPath,
  57.     BBFutureUse: String;
  58.  
  59. implementation
  60.  
  61. {$R *.DFM}
  62.  
  63.  
  64. procedure TForm1.ThreeButtonClick(Sender: TObject);
  65. // Temporarily Disable Burn CD button to avoid double clicks
  66. // Copy desired files to \Bin\FilesToBackup\ folder
  67. // Fill in registration numbers, and
  68. // OPTIONAL- Fill in desired Volume name (to be burned as CD title) or use null '';
  69. // Hide or minimize your program
  70. // Launch MakeBackupCD function in BackupBurner.dll
  71. // When function returns, the CD process is complete.
  72. // Unhide or restore your program
  73. // OPTIONAL- Inspect the result code
  74. // OPTIONAL- delete unneeded files from \Bin\FilesToBackup\
  75. // You are done.
  76. var
  77.   H: THandle;
  78.   MakeBackupCD: function(BBRegName, BBRegCode, BBVolume, BBTitle, BBColorForm, BBColorText, BBFolderPath, BBFutureUse: PChar): integer; stdcall;
  79. begin
  80. // Temporarily Disable Burn CD button to avoid double clicks
  81.     Button3.Enabled := False;
  82.  
  83. // Copy desired files to \Bin\FilesToBackup\ folder (or use the files selected by the #2 button)
  84.     CopyFile(Pchar('\Automenu\AutoRun.exe'), Pchar('Bin\FilesToBackup\AutoRun.exe'),FALSE );
  85.     CopyFile(Pchar('\Automenu\AutoRun.inf'), Pchar('Bin\FilesToBackup\AutoRun.inf'),FALSE );
  86.  
  87. // Fill in registration numbers, and
  88. // OPTIONAL- Fill in desired Volume name (to be burned as CD title) or use null '';
  89.  
  90.     BBRegName   :=  'DEMOUSER';
  91.     BBRegCode   :=  'ABCD1234';
  92.     BBVolume    :=  'MyBackupCD'; //' What ever you want here, but no spaces allowed
  93.     BBTitle     :=  Memo1.Lines[0] + Memo1.Lines[1] ;//This is your program title to display on the recording form.
  94.     BBColorForm :=  'clSilver';//default is clSilver, don't use hex color
  95.     BBColorText :=  'clBlack';//default is clBlack, don't use hex color
  96.     BBFolderPath:=  ExtractFilePath(ParamStr(0))  + 'FilesToBackup\'; // Make this any folder containing your desired files.
  97.     BBFutureUse :=  '';
  98.  
  99. // Hide or minimize your program
  100.    Application.Minimize;
  101.  
  102. // Launch MakeBackupCD function in BackupBurner.dll
  103. // When function returns, the CD process is complete...
  104.   If FileExists(ExtractFilePath(ParamStr(0))  + 'Bin\'+ 'BackupBurner.dll') then
  105.    begin
  106.     ResultCode := 100;
  107.     H := LoadLibrary( Pchar(ExtractFilePath(ParamStr(0))  + 'Bin\'+ 'BackupBurner.dll') );
  108.     if  H <> NULL then
  109.       begin
  110.         try
  111.             @MakeBackupCD := GetProcAddress(H, 'MakeBackupCD');
  112.             if  Assigned(MakeBackupCD)   then
  113.             ResultCode := MakeBackupCD(PChar(BBRegName), PChar(BBRegCode), PChar(BBVolume), PChar(BBTitle), PChar(BBColorForm), PChar(BBColorText), PChar(BBFolderPath), PChar(BBFutureUse) );
  114.         finally
  115.             FreeLibrary(H);
  116.         end;
  117.       end;
  118.    end
  119.    else
  120.    begin
  121.     ResultsLabel.Caption := 'Result: BackupBurner.dll file not found in the path ';
  122.     Application.Restore;
  123.     Sleep(5000);
  124.     close;
  125.    end;
  126.  
  127. // Now the CD process is complete.
  128. // Unhide or restore your program
  129.     Application.Restore;
  130.     Button3.Enabled := True;
  131.  
  132. // OPTIONAL- Inspect the result code
  133.     Case ResultCode of
  134.    -2: ResultsLabel.Caption := 'Result: ResultCode = -2 Installation Error- version mismatch';
  135.    -1: ResultsLabel.Caption := 'Result: ResultCode = -1 User canceled' ;
  136.     0: ResultsLabel.Caption := 'Result: ResultCode = 0  it was a successful burn!';
  137.     1: ResultsLabel.Caption := 'Result: ResultCode = 1  User canceled';
  138.     2: ResultsLabel.Caption := 'Result: ResultCode = 2  Installation Error- files missing';
  139.     3: ResultsLabel.Caption := 'Result: ResultCode = 3  Insufficent disk space';
  140.     5: ResultsLabel.Caption := 'Result: ResultCode = 5  there was not a blank CD';
  141.     7: ResultsLabel.Caption := 'Result: ResultCode = 7  bad burn during writing ';
  142.     8: ResultsLabel.Caption := 'Result: ResultCode = 8  no CD recorder detected. ';
  143.     9: ResultsLabel.Caption := 'Result: ResultCode = 9  Demo expired. ';
  144.    11: ResultsLabel.Caption := 'Result: ResultCode = 11 User does not have admin rights to access the ASPI manager. ';
  145.     else
  146.      ResultsLabel.Caption := 'Result: There was an unknown result.';
  147.     end;
  148.  
  149. // OPTIONAL- delete unneeded files from \Bin\FilesToBackup\
  150.     DeleteFile(Pchar('Bin\FilesToBackup\Example.txt'));
  151.  
  152. // You are done.
  153. end;
  154.  
  155.  
  156. procedure TForm1.TwoButtonClick(Sender: TObject);
  157. begin
  158.   if OpenDialog1.Execute then  { Display Open dialog box }
  159.   begin
  160.     CopyFile(Pchar(OpenDialog1.FileName),Pchar(ExtractFilePath(ParamStr(0))+ '\Bin\FilesToBackup\'+ ExtractFileName(OpenDialog1.FileName)),FALSE  );
  161.   end;
  162. end;
  163.  
  164. procedure TForm1.ExitClick(Sender: TObject);
  165. begin
  166.     Close;
  167. end;
  168.  
  169. end.
  170.